#ifndef __OBJECT_H__
#define __OBJECT_H__


#include <AGTRenderSystem/RenderManager.h>
#include "Ogre.h"
#include "Component.h"


#include <vector>
#include <string>

using namespace std;

class Component;

typedef vector<Component*> ComponentVector;

class Object
{
protected:
	int					m_uID;				// Unique ID number for the object
	std::string			m_name;				// Name of the object. Not necessarily unique
	ComponentVector		m_Components;		// Storage of vector components
	ComponentVector::iterator it;			// Iterator for component vector

	static int sID;


	// Objects are unique throughout all scene. An object doesn't neccessarily require a scene.
	// The owner scene is required for renderer components.

public:


	Object();
	Object(string name);


	virtual ~Object(){};

	virtual void ManageComponent(Component* comp);		// Adds and manages the components to vector
	virtual Component* getComponent(string familyType, string componentType);
	virtual bool isComponentInStore(Component *comp);	// Checks to see if component is already in store
	virtual void clearComponents();						// Removes all components of an object
	virtual void updateComponents();					// Update all the components
	virtual void objectUpdate()=0;						// Update objects -- For message handling

	int getID(void){ return m_uID; }					// Get the id of the object
	string getName(void){ return m_name; }				// Return name of the object
};


//=========================

/*
	Object factory class
*/
class ObjectFactory
{
};


/*
	Object Manager:
	Handles addition and deletion of objects in a scene and object updates.
	None singleton class, since each scene has its store of objects through
	the object manager.
*/
class ObjectManager
{
private:	// Attributes
	vector<Object*> m_objects;
	vector<Object*>::iterator it;
public:
	ObjectManager();	// Initialises the vector storage of objects
	~ObjectManager();

	void manageObject(Object* obj);		// Adds an object to the manager
	Object* getObject(int id);			// Get an object by ID
	bool isObjectInStore(Object* obj);	// Checks to see if object is in storage
	void clearObjects(void);			// Clears all object from vector store
	void updateObjects(void);			// Updates all objects in scene
};

#endif